#include<iostream>
#include<functional>
using namespace std;

struct Test
{
	int value;
	int value2;
	int fun(int i)
	{
		return i * value2;
	}
};

int main(void)
{
	Test t1{100, 200};
	Test t2{300, 400};
	
	function<int(Test&)> f1 = &Test::value;
	cout<< f1(t1) <<endl;		//f1(t1) <=> t1.*f1;
	
	function<int(Test*)> f2 = &Test::value2;
	cout<< f2(&t2) <<endl;		//f2(&t2) <=> t2.*f2
	
	function<int(Test&, int)> f3 = &Test::fun;
	cout<< f3(t1, 300) <<endl;	//<=> t1.f3(300)
	
	function<int(Test*, int)> f4 = &Test::fun;
	cout<< f4(&t2, 500) <<endl;
	
	return 0;
}
